﻿<%@ Page Title="Club List" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="ClubList.aspx.vb" Inherits="WSAD_Assignment.ClubList" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    
    <h3 class="form-signup-heading">Club List</h3>
        
    <asp:LinkButton ID="btnAddNewClub" 
            runat="server"
            CssClass="btn btn-primary"    
            OnClick="btnAddNewClub_Click">
            <i aria-hidden="true" class="glyphicon glyphicon-plus"></i> Add New Club
    </asp:LinkButton>
    <asp:LinkButton ID="btnRSSFeed" 
            runat="server"
            CssClass="btn btn-primary"    
            OnClick="btnRSSFeed_Click">
            <i aria-hidden="true" class="glyphicon glyphicon-bullhorn"></i> RSS Feed
    </asp:LinkButton><br /><br />

    <asp:UpdatePanel id="upClubList" runat="server">
        <ContentTemplate>
            <asp:PlaceHolder ID="phSearch" runat="server">
                <asp:TextBox ID="txtSearch" name="txtSearch" runat="server" CssClass="form-control search" placeholder="Club Search" Width="200px"></asp:TextBox>
                <asp:PlaceHolder ID="phSearchButton" runat="server"></asp:PlaceHolder>
                <asp:Button ID="btnSearch" 
                    runat="server"
                    CssClass="btn btn-primary search"
                    Text=" ">
                </asp:Button>
        
                <asp:DropDownList ID="ddlCountry" name="ddlCountry" runat="server" DataSourceID="CountriesDataSource" DataTextField="CountryName" DataValueField="CountryName" CssClass="form-control search"
                    AppendDataBoundItems="true" AutoPostBack="true" Width="200px">
                    <asp:ListItem Text="All Countries" Value="" />
                </asp:DropDownList>
                <asp:SqlDataSource ID="CountriesDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ClubsConnectionString %>" ProviderName="<%$ ConnectionStrings:ClubsConnectionString.ProviderName %>"
                         SelectCommand="SELECT [CountryName] FROM [Countries]"></asp:SqlDataSource>
        
                <br /><br />
            </asp:PlaceHolder>

            <asp:Panel ID="pnlUserMessage_Error" CssClass="bg-danger" Visible="False" runat="server">
                <asp:Label ID="lblUserMessage_Error" runat="server"></asp:Label>
            </asp:Panel>

            <asp:GridView ID="gvClubList" runat="server" CssClass="table table-hover table-striped table-bordered table-condensed" AutoGenerateColumns="False" 
                DataSourceID="ClubListDataSource" AllowPaging="True" GridLines="None" AllowSorting="True" EmptyDataText="No records found for the search criteria">
                    <Columns>
                        <asp:HyperLinkField DataNavigateUrlFields="ID" DataNavigateUrlFormatString="ClubDetail.aspx?ClubID={0}" DataTextField="ClubName" HeaderText="Name" SortExpression="ClubName" />
                        <asp:BoundField DataField="FoundationDate" HeaderText="Foundation Date" SortExpression="FoundationDate" DataFormatString="{0:dd/MM/yyyy}" />
                        <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />
                        <asp:BoundField DataField="CountryName" HeaderText="Country" SortExpression="CountryName" />
                        <asp:TemplateField HeaderText="Emblem">
                            <ItemTemplate>
                                <a href='ClubDetail.aspx?ClubID=<%# Eval("ID")%>'>
                                    <img src='<%# Eval("Emblem")%>' width="100px" height="100px" />
                                </a>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle CssClass="cursor-pointer" />
            </asp:GridView>

            <asp:SqlDataSource ID="ClubListDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ClubsConnectionString %>" ProviderName="<%$ ConnectionStrings:ClubsConnectionString.ProviderName %>" 
                SelectCommand="SELECT [ID], [ClubName], [FoundationDate], [Address], [CountryName], [Emblem] FROM [ClubList] ORDER BY [ClubName] ASC"
                FilterExpression="([ClubName] LIKE '%{0}%') AND ([CountryName] LIKE '%{1}%')">
                <FilterParameters>
                    <asp:ControlParameter Name="ClubName" ControlID="txtSearch" PropertyName="Text" ConvertEmptyStringToNull="False" />
                    <asp:ControlParameter Name="CountryName" ControlID="ddlCountry" PropertyName="SelectedValue" ConvertEmptyStringToNull="False" />
                </FilterParameters>
            </asp:SqlDataSource>
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
